#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(int argc, char** argv) {
    double c[4] = {1.0, 1.2, 3.0, 3.2};
    double a[4][6] = {10.0, 3.0, 17.0, 3.5, 1.7, 8.0, 0.05, 10.0, 17.0, 0.1, 8.0, 14.0, 3.0, 3.5, 1.7, 10.0, 17.0, 8.0, 17.0, 8.0, 0.05, 10.0, 0.1, 14.0};
    double p[4][6] = {0.1312, 0.1696, 0.5569, 0.0124, 0.8283, 0.5886, 0.2329, 0.4135, 0.8307, 0.3736, 0.1004, 0.9991, 0.2348, 0.1451, 0.3522, 0.2883, 0.3047, 0.665, 0.4047, 0.8828, 0.8732, 0.5743, 0.1091, 0.0381};
    double x[6] = {0.20169, 0.150011, 0.476874, 0.275332, 0.311652, 0.657301};

    double sum1 = 0;
    double sum2 = 0;

    for (int i = 0; i < 4; i++) {
        sum1 = 0;
        for (int j = 0; j < 6; j++)
            sum1 += a[i][j] * pow((x[j] - p[i][j]), 2);
        sum2 += c[i] * exp((-1) * sum1);
    }

    double fitness = (-1) * sum2;
    cout << "Fitness = " << fitness << endl;
    return 0;
}
